using System.Windows.Input;
using Avalonia;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace AvaloniaUI.Modal.Demo.ViewModels
{
    /// <summary>
    /// 消息对话框ViewModel
    /// </summary>
    public partial class MessageDialogViewModel : ViewModelBase
    {
        /// <summary>
        /// 标题
        /// </summary>
        [ObservableProperty]
        private string _title = "消息";

        /// <summary>
        /// 消息内容
        /// </summary>
        [ObservableProperty]
        private string _message = string.Empty;

        /// <summary>
        /// 确认按钮文本
        /// </summary>
        [ObservableProperty]
        private string _okText = "确定";

        /// <summary>
        /// 取消按钮文本
        /// </summary>
        [ObservableProperty]
        private string _cancelText = "取消";

        /// <summary>
        /// 是否显示取消按钮
        /// </summary>
        [ObservableProperty]
        private bool _showCancel = true;

        /// <summary>
        /// 对话框结果
        /// </summary>
        public bool? DialogResult { get; private set; }

        /// <summary>
        /// 确认命令
        /// </summary>
        [RelayCommand]
        private void Ok()
        {
            DialogResult = true;
            Application.Current?.GetModalService().CloseDialog(true);
        }

        /// <summary>
        /// 取消命令
        /// </summary>
        [RelayCommand]
        private void Cancel()
        {
            DialogResult = false;
            Application.Current?.GetModalService().CloseDialog(false);
        }
    }
}